{% extends "base.html" %}

{% block title %}编辑品种 - 交易监控系统{% endblock %}

{% block content %}
<div class="page-header">
    <h1>编辑品种</h1>
    <a href="/products" class="btn btn-secondary">
        <i class="fas fa-arrow-left"></i> 返回列表
    </a>
</div>

<div class="card">
    <div class="card-header">
        <h2>品种信息</h2>
    </div>
    <div class="card-body">
        {% if request.url.path.startswith('/monitored_products') %}
        <form action="/monitored_products/{{ product.id }}/edit" method="post">
        {% else %}
        <form action="/products/{{ product.id }}/edit" method="post">
        {% endif %}
            <input type="hidden" name="from" value="{{ request.query_params.get('from', '') }}">
            <input type="hidden" name="referer" value="{{ request.headers.get('referer') }}">
            <div class="form-group">
                <label for="name">品种名称</label>
                <input type="text" id="name" name="name" class="form-control" value="{{ product.name }}" required>
            </div>
            
            <div class="form-group">
                <label for="exchange_code">交易代码</label>
                <input type="text" id="exchange_code" name="exchange_code" class="form-control" value="{{ product.exchange_code }}" required>
            </div>
            
            <div class="form-group">
                <label for="margin">保证金</label>
                <input type="number" id="margin" name="margin" class="form-control" step="0.01" value="{{ product.margin }}" required>
            </div>
            
            <div class="form-group">
                <label for="stoploss">止损点数</label>
                <input type="number" id="stoploss" name="stoploss" class="form-control" step="0.01" value="{{ product.stoploss }}" required>
            </div>
            
            <div class="form-group">
                <label for="takeprofit">止盈点数</label>
                <input type="number" id="takeprofit" name="takeprofit" class="form-control" step="0.01" value="{{ product.takeprofit }}" required>
            </div>
            
            <div class="form-group">
                <label for="limit_stoploss">止损限制</label>
                <input type="number" id="limit_stoploss" name="limit_stoploss" class="form-control" step="0.01" value="{{ product.limit_stoploss }}" required>
            </div>
            
            <div class="form-group">
                <label for="mtp">止盈止损周期</label>
                <input type="text" id="mtp" name="mtp" class="form-control" value="{{ product.mtp }}" required>
            </div>
            
            <div class="form-group">
                <label for="dks">开仓方向</label>
                <select id="dks" name="dks" class="form-control" required>
                    <option value="双向" {% if product.dks == '双向' %}selected{% endif %}>双向</option>
                    <option value="只做多" {% if product.dks == '只做多' or product.dks == '仅多头' %}selected{% endif %}>只做多</option>
                    <option value="只做空" {% if product.dks == '只做空' or product.dks == '仅空头' %}selected{% endif %}>只做空</option>
                    <option value="不开仓仅止损" {% if product.dks == '不开仓仅止损' %}selected{% endif %}>不开仓仅止损</option>
                </select>
            </div>
            
            <div class="form-group">
                <label for="is_monitored">监控状态</label>
                <select id="is_monitored" name="is_monitored" class="form-control" required>
                    <option value="1" {% if product.is_monitored == 1 %}selected{% endif %}>监控中</option>
                    <option value="0" {% if product.is_monitored == 0 %}selected{% endif %}>未监控</option>
                </select>
            </div>
            
            <button type="submit" class="btn btn-primary">
                <i class="fas fa-save"></i> 保存
            </button>
        </form>
    </div>
</div>
{% endblock %}